package codingforgreat.lchot150;

public class Lc189 {
    public void rotate(int[] nums, int k) {
        k = k % nums.length;
        reverse(nums,0,nums.length - k - 1);
        reverse(nums,nums.length - k,nums.length - 1);
        reverse(nums,0,nums.length - 1);

    }
    public void reverse(int[] nums,int L,int R){//下标 i-j 逆序
        while (L < R) {
            int tmp = nums[L];
            nums[L++] = nums[R];
            nums[R--] = tmp;
        }
    }
}
